<!DOCTYPE html>
<html>

	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
		<meta name="apple-mobile-web-app-capable" content="yes">
		<meta name="apple-mobile-web-app-status-bar-style" content="black">
		<link rel="stylesheet" type="text/css" href="../../css/mui.min.css" />
		<script src="../../js/mui.min.js" type="text/javascript" charset="utf-8"></script>
		<style>
			.main_content p {
				font-size: 1em;
				color: black;
				text-indent: 2em;
				padding: 6px;
			}
			.main_content img {
				padding: 8px;
			}
			.sub_header {
				text-align: center;
				background-color: rgba(0, 188, 0, 0.7);
				height: 36px;
				margin-top: 8px;
				margin-bottom: 8px;
			}
			.sub_header h3 {
				color: white;
				position: relative;
				top: 20%;
				transform: translateY(-50%);
			}
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav">
			<a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
			<h1 class="mui-title">Java 基础</h1>
		</header>
		<div class="mui-content">
			<div class="mui-content-padded" style="margin: 5px;">
				<div class="sub_header">
					<h3>normal</h3>
				</div>
				<div class="main_content">
					<p><span style="background-color:rgb(230, 230, 250)"><span style="color:rgb(255, 0, 0)">2015年4月某天下午，我又像往常一样串到隔壁寝室向大师（孤星可，外号大师）求取真经，适逢大师在给小蔡、30 二人传达组建团队一齐用java重写typecho的提议，而我也希望能在实践中学习，因此一起参与了该项目，于是我们的团队&ldquo;三分稚气&rdquo;就此诞生，开始编写typecho的java实现。</span></span>
					</p>

					<hr />
					<p>在这个项目开发过程之中，得到了大师不少点拨，也接触到了以前从未了解过的东西（Maven、Git），起初并不太清楚这俩儿哥们有啥用，后来我查阅相关文档以及一些教程才懵懵懂懂，随着项目历程的进行也确实感受到了它们的便利之处，但毕竟只是以一个项目成员的身份参与项目开发，对诸如maven的pom.xml配置和git的完整流程并不太清楚，直到后来独立开发了自己的博客CBlog，才对它们有了更加深刻的认识，着实体悟到了这两种技术的强大于便利。</p>

					<p>先如今初步学习了三大框架之中的Spring，了解到Spring对jdbc的支持之后，想起来当时参与开发typecho4j之时编写后台代码部分与之有相似之处，该部分的CURD操作存在大量冗余重复的jdbc代码，于是我对原生的jdbc加以封装过，同时也写了一些特别的工具方法，特此记录下来，以便后期改良复用，倘若再能触发读者的一丝灵感，不胜荣幸！</p>

					<hr />
					<div style="border: 1px solid rgb(204, 204, 204); padding: 5px 10px; background: rgb(238, 238, 238);">&nbsp; &nbsp;<span style="color:#FFFFFF"><span style="background-color:#000000">以下代码为当时我对jdbc的一些简单封装</span></span>
					</div>

					<div style="border: 1px solid rgb(204, 204, 204); padding: 5px 10px; background: rgb(238, 238, 238);">
						<p>/**
							<br /> &nbsp;&nbsp; &nbsp; * 根据传进参数对PreparedStatement对象进行填充
							<br /> &nbsp;&nbsp; &nbsp; *&nbsp;
							<br /> &nbsp;&nbsp; &nbsp; * @param pstmt
							<br /> &nbsp;&nbsp; &nbsp; * @param objects
							<br /> &nbsp;&nbsp; &nbsp; */
							<br /> &nbsp;&nbsp; &nbsp;public static void fillPreparedStatement(PreparedStatement pstmt,
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;List
							<object>objects) {
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;try {
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for (int i = 0; i &lt; objects.size(); i++) {
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (objects.equals(null)) {
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pstmt.setObject(i + 1, null);
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} else {
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pstmt.setObject(i + 1, objects.get(i));
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} catch (Exception e) {
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;e.printStackTrace();
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
								<br /> &nbsp;&nbsp; &nbsp;}</object>
						</p>

						<p>&nbsp;&nbsp; &nbsp;/**
							<br /> &nbsp;&nbsp; &nbsp; * 根据表名和增加条件添加记录
							<br /> &nbsp;&nbsp; &nbsp; *&nbsp;
							<br /> &nbsp;&nbsp; &nbsp; * @param tableName
							<br /> &nbsp;&nbsp; &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;表名
							<br /> &nbsp;&nbsp; &nbsp; * @param addCondition
							<br /> &nbsp;&nbsp; &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;增加条件
							<br /> &nbsp;&nbsp; &nbsp; * @param object
							<br /> &nbsp;&nbsp; &nbsp; * @return boolean
							<br /> &nbsp;&nbsp; &nbsp; */
							<br /> &nbsp;&nbsp; &nbsp;public static boolean addRecord(String tableName, String addCondition,
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Object object) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;try {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;con = getLocalCon();
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;String sql = &quot;insert into &quot; + tableName + &quot; &quot; + addCondition;
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// 根据表名返回全部字段的集合</p>

						<p>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;List result = DbUtil.getColumnNameByTableName(con,
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;tableName);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// 第一列为主键不能更新，从list中删除</p>

						<p>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (!&quot;t_options&quot;.equals(tableName)) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;result.remove(0);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// 根据剩下的表中字段和Object对象，调用相对应的get方法，得到的返回值存放到List
							<object>中</object>
						</p>

						<p>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;List
							<object>objects = OtherUtil.getValueByTabColum(result,
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;object);
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;PreparedStatement pstmt = con.prepareStatement(sql);
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// 调用工具类填充pstmt</object>
						</p>

						<p>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;fillPreparedStatement(pstmt, objects);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pstmt.executeUpdate();
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} catch (Exception e) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;e.printStackTrace();
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return false;
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} finally {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;try {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;closeLocalCon(con);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} catch (Exception e) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;e.printStackTrace();
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return true;
							<br /> &nbsp;&nbsp; &nbsp;}</p>

						<p>&nbsp;&nbsp; &nbsp;/**
							<br /> &nbsp;&nbsp; &nbsp; * 根据表名和条件删除记录
							<br /> &nbsp;&nbsp; &nbsp; *&nbsp;
							<br /> &nbsp;&nbsp; &nbsp; * @param tableName
							<br /> &nbsp;&nbsp; &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;表名
							<br /> &nbsp;&nbsp; &nbsp; * @param condition
							<br /> &nbsp;&nbsp; &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;删除条件
							<br /> &nbsp;&nbsp; &nbsp; * @param object
							<br /> &nbsp;&nbsp; &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;条件的值
							<br /> &nbsp;&nbsp; &nbsp; * @return boolean
							<br /> &nbsp;&nbsp; &nbsp; */
							<br /> &nbsp;&nbsp; &nbsp;public static boolean deleteRecord(String tableName,
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;String deleteCondition, Object object) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;try {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;con = getLocalCon();
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;String sql = &quot;delete from &quot; + tableName + &quot; &quot; + deleteCondition + &quot;=?&quot;;
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;PreparedStatement pstmt = con.prepareStatement(sql);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pstmt.setObject(1, object);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pstmt.executeUpdate();
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} catch (Exception e) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;e.printStackTrace();
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return false;
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} finally {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;try {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;closeLocalCon(con);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} catch (Exception e) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;e.printStackTrace();
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return true;
							<br /> &nbsp;&nbsp; &nbsp;}</p>

						<p>&nbsp;&nbsp; &nbsp;public static boolean updateRecord(String tableName,
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;String updateCondition, Object object, Object primaryKeyValue) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;try {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;con = getLocalCon();
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;List result = DbUtil.getColumnNameByTableName(con,
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;tableName);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;// 删除表中主键以及某些不可更改的项</p>

						<p>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (&quot;t_user&quot;.equals(tableName)) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;result.remove(&quot;uid&quot;);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;result.remove(&quot;username&quot;);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;result.remove(&quot;created&quot;);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} else if (&quot;t_metas&quot;.equals(tableName)) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;result.remove(&quot;mid&quot;);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} else if (&quot;t_contents&quot;.equals(tableName)) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;result.remove(&quot;cid&quot;);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;result.remove(&quot;type&quot;);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;result.remove(&quot;created&quot;);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;List
							<object>objects = OtherUtil.getValueByTabColum(result,
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;object);
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;result.add(updateCondition);
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;objects.add(primaryKeyValue);
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;DbUtil.updateByTableAndFields(con, tableName, result, objects);
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} catch (Exception e) {
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;e.printStackTrace();
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return false;
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} finally {
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;try {
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;closeLocalCon(con);
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} catch (Exception e) {
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;e.printStackTrace();
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return true;
								<br /> &nbsp;&nbsp; &nbsp;}</object>
						</p>

						<p>&nbsp;&nbsp; &nbsp;/**
							<br /> &nbsp;&nbsp; &nbsp; * 数据库更新方法
							<br /> &nbsp;&nbsp; &nbsp; *&nbsp;
							<br /> &nbsp;&nbsp; &nbsp; * @param con
							<br /> &nbsp;&nbsp; &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;数据库连接
							<br /> &nbsp;&nbsp; &nbsp; * @param tableName
							<br /> &nbsp;&nbsp; &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;根据表名更新对应表
							<br /> &nbsp;&nbsp; &nbsp; * @param fieldsName
							<br /> &nbsp;&nbsp; &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;根据传进的字段名加以判断，若该字段名不为空则更新该字段
							<br /> &nbsp;&nbsp; &nbsp; * @param objects
							<br /> &nbsp;&nbsp; &nbsp; * &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;传进字段所对应的值
							<br /> &nbsp;&nbsp; &nbsp; * @return Boolean（更新成功返回True，失败返回False）
							<br /> &nbsp;&nbsp; &nbsp; */
							<br /> &nbsp;&nbsp; &nbsp;public static boolean updateByTableAndFields(Connection con,
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;String tableName, List fieldsName, List
							<object>objects) {
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;StringBuilder sb = new StringBuilder();
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;String updateCondition = null;
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;List
								<object>selectedObjects = new ArrayList
									<object>();
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for (int i = 0; i &lt; objects.size(); i++) {
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (objects.get(i) == null) {
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;continue;
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;selectedObjects.add(objects.get(i));
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;if (i != objects.size() - 1) {
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;sb.append(&quot;,&quot; + &quot;`&quot; + fieldsName.get(i) + &quot;`&quot; + &quot;=?&quot;);
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;continue;
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;updateCondition = &quot; &quot; + fieldsName.get(i) + &quot;=?&quot;;
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;String str = sb.substring(1);
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;String sql = &quot;update &quot; + tableName + &quot; set &quot; + str + updateCondition;
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;PreparedStatement pstmt;
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;try {
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pstmt = con.prepareStatement(sql);
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for (int k = 0; k &lt; selectedObjects.size(); k++) {
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pstmt.setObject(k + 1, selectedObjects.get(k));
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;pstmt.executeUpdate();
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} catch (SQLException e) {
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;e.printStackTrace();
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return false;
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return true;
										<br /> &nbsp;&nbsp; &nbsp;}</object>
								</object>
							</object>
						</p>
					</div>

					<hr />
					<div style="background:#eee;border:1px solid #ccc;padding:5px 10px;"><span style="color:#FFFFFF"><span style="background-color:#000000">以下为当时写的一些简单工具方法</span></span>
					</div>

					<div style="background:#eee;border:1px solid #ccc;padding:5px 10px;">
						<p>/**
							<br /> &nbsp;&nbsp; &nbsp; * 根据表名返回全部字段名的一个List
							<br /> &nbsp;&nbsp; &nbsp; *&nbsp;
							<br /> &nbsp;&nbsp; &nbsp; * @param con
							<br /> &nbsp;&nbsp; &nbsp; * @param table
							<br /> &nbsp;&nbsp; &nbsp; * @return List
							<br /> &nbsp;&nbsp; &nbsp; */
							<br /> &nbsp;&nbsp; &nbsp;public static List getColumnNameByTableName(Connection con,
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;String table) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;List columList = new ArrayList();
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;try {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;String sql = &quot;select * from &quot; + table + &quot; where 1=3&quot;;
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;PreparedStatement pstmt = con.prepareStatement(sql);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;ResultSet rs = pstmt.executeQuery();
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;ResultSetMetaData data = rs.getMetaData();
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for (int i = 1; i &lt;= data.getColumnCount(); i++) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;columList.add(data.getColumnName(i));
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} catch (SQLException e) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;e.printStackTrace();
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return columList;
							<br /> &nbsp;&nbsp; &nbsp;}</p>

						<p>/**
							<br /> &nbsp;&nbsp; &nbsp; * 根据表的列名返回对应get方法返回值的一个List集合
							<br /> &nbsp;&nbsp; &nbsp; *&nbsp;
							<br /> &nbsp;&nbsp; &nbsp; * @param result
							<br /> &nbsp;&nbsp; &nbsp; * @param object
							<br /> &nbsp;&nbsp; &nbsp; * @return List
							<br /> &nbsp;&nbsp; &nbsp; */
							<br /> &nbsp;&nbsp; &nbsp;public static List
							<object>getValueByTabColum(List result, Object object) {
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;List strList = new ArrayList();
								<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;List
								<object>objList = new ArrayList
									<object>();
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for (String string : result) {
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;char[] ch = string.toCharArray();
										<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;//把ch的第0位进行字母的ASCII码前移，实现首字母转大写</object>
								</object>
							</object>
						</p>

						<p>&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;ch[0] -= 32;
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;strList.add(&quot;get&quot; + String.valueOf(ch));
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Class
							<!--?-->c = object.getClass();
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;for (String string : strList) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Method mthod;
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;try {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;mthod = c.getDeclaredMethod(string);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Object obj = mthod.invoke(object);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;objList.add(obj);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;} catch (Exception e) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;e.printStackTrace();
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;}
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return objList;
							<br /> &nbsp;&nbsp; &nbsp;}</p>
					</div>

					<hr />
					<div style="background:#eee;border:1px solid #ccc;padding:5px 10px;">&nbsp;<span style="color:#FFFFFF"><span style="background-color:#000000">以下为<strong>MetaDaoJdbcImpl类的某些CRUD方法调用上述工具类后的实现</strong></span></span>
					</div>

					<div style="background:#eee;border:1px solid #ccc;padding:5px 10px;">
						<p>/**
							<br /> &nbsp;&nbsp; &nbsp; * 在数据库增加Meta记录
							<br /> &nbsp;&nbsp; &nbsp; *&nbsp;
							<br /> &nbsp;&nbsp; &nbsp; * @return boolean
							<br /> &nbsp;&nbsp; &nbsp; */
							<br /> &nbsp;&nbsp; &nbsp;@Override
							<br /> &nbsp;&nbsp; &nbsp;public boolean addMeta(MetaDmo metaDmo) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;String condition = &quot;values(null,?,?,?,?,?,?)&quot;;
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;boolean bool = DbUtil.addRecord(this.TABLE_NAME, condition, metaDmo);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return bool;
							<br /> &nbsp;&nbsp; &nbsp;}</p>

						<p>&nbsp;&nbsp; &nbsp;/**
							<br /> &nbsp;&nbsp; &nbsp; * 根据metaId删除t_metas表中的记录
							<br /> &nbsp;&nbsp; &nbsp; *&nbsp;
							<br /> &nbsp;&nbsp; &nbsp; * @return boolean
							<br /> &nbsp;&nbsp; &nbsp; */
							<br /> &nbsp;&nbsp; &nbsp;@Override
							<br /> &nbsp;&nbsp; &nbsp;public boolean deleteMeta(Integer metaId) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;String foreignTable = &quot;t_relationships&quot;;
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;String condition = &quot;where `mid`&quot;;
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;boolean bool1 = DbUtil.deleteRecord(foreignTable, condition, metaId);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;boolean bool2 = DbUtil.deleteRecord(this.TABLE_NAME, condition, metaId);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return bool1 &amp;&amp; bool2;
							<br /> &nbsp;&nbsp; &nbsp;}</p>

						<p>&nbsp;&nbsp; &nbsp;/**
							<br /> &nbsp;&nbsp; &nbsp; * 更新Meta记录
							<br /> &nbsp;&nbsp; &nbsp; *&nbsp;
							<br /> &nbsp;&nbsp; &nbsp; * @return boolean
							<br /> &nbsp;&nbsp; &nbsp; */
							<br /> &nbsp;&nbsp; &nbsp;@Override
							<br /> &nbsp;&nbsp; &nbsp;public boolean updateMeta(MetaDmo metaDmo) {
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;String updateCondition = &quot;where `mid`&quot;;
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;Integer pkValue = metaDmo.getId();
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;boolean bool = DbUtil.updateRecord(this.TABLE_NAME, updateCondition,
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;metaDmo, pkValue);
							<br /> &nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;return bool;
							<br /> &nbsp;&nbsp; &nbsp;}</p>
					</div>

				</div>
			</div>
		</div>

	</body>

</html>